#ifndef VERTEXIMPL_H
#define VERTEXIMPL_H

#include "Vertex.h"
#include <map>

namespace GoodGraphs {

template <typename T>

class VertexImpl : public Vertex<T>
{
private:
    T id;
    std::multimap<T, Edge*> edges;
public:
    virtual ~VertexImpl();
    void addEdge(Edge * param);
    bool removeEdge(Edge * param);
    VertexImpl(T id);
    T getId() = 0;
    std::multimap<T, Edge*>::iterator begin();
    std::multimap<T, Edge*>::iterator end();
    virtual bool operator<(Vertex<T>& otherParam);
};

VertexImpl::VertexImpl(T id):id(id){

}

VertexImpl::~VertexImpl(){

}

void VertexImpl::addEdge(Edge * param){
    Vertex* v1 = param->getOtherSide(this);
    int to = v1->getId();
    std::pair<int, Edge*> toAdd(to, param);
    archi.insert(toAdd);
}

bool VertexImpl::removeEdge(Edge * param){
    Vertex* v1 = param->getOtherSide(this);
    int to = v1->getId();
    archi.erase(to);
}

T VertexImpl::getId(){
    return id;
}

std::multimap<T, Edge*>::iterator VertexImpl::begin(){
    return edges.begin();
}

std::multimap<T, Edge*>::iterator VertexImpl::end(){
    return edges.end();
}

bool VertexImpl::operator<(Vertex<T>& otherParam){
    return id < otherParam.getId();
}


}


#endif //VERTEXIMPL_H
